﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Commonlib;
namespace AlbonWeb.Manager.StyleManager
{
    public partial class PrintStyle : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                //绑定最顶层样式 
                string cmdstr = "select * from Style where parentID=0";
                SqlHelper.BindDropDownList(ddlTop, "styleName", "ID", SqlHelper.SqlConnectionString, CommandType.Text, cmdstr, null);
                ddlTop.Items.Insert(0, "--select style--");
            }
        }
        //绑定样式 
        protected void ddlTop_SelectedIndexChanged(object sender, EventArgs e)
        {
            string cmdstr = "select * from Style where ID=" + ddlTop.SelectedValue; 
            SqlHelper.BindRepeater(repTopStyle, SqlHelper.SqlConnectionString, CommandType.Text, cmdstr, null);
        }
        protected void bindStyle(Repeater rep, string parentid)
        {
            string cmdstr = "select * from Style where parentID=" + parentid+" order by sequence asc";
            SqlHelper.BindRepeater(rep, SqlHelper.SqlConnectionString, CommandType.Text, cmdstr, null);
        }

        //绑定父样式
        protected void repTopStyle_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            string parentid = ((HiddenField)e.Item.FindControl("hftopstyle")).Value;
            Repeater rep = (Repeater)e.Item.FindControl("repStyle");
            bindStyle(rep, parentid);
        }

        //绑定样式值
        protected void repStyle_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            string parentid = ((HiddenField)e.Item.FindControl("hfparentid")).Value;
            Repeater rep = (Repeater)e.Item.FindControl("repValue");
            bindStyle(rep, parentid);
        }

        
    }
}